const app = getApp();
var openId = null
let jinbiShareLgImg = ''
let jinbiShareMinImg = ''
let jinbiShareText = ''
Page({
  data: {
    teziIsShow:false,
    jinbi: 0,
    xianjin: 0,
  },
  onLoad() {
    // 获取全局分享媒体资源
    this.getShareImg()
  },
  // 获取分享图片及文案
  getShareImg() {
    if(!app.globalData.getGlobalShareMedia){
      jinbiShareLgImg = app.globalData.getGlobalShareMedia.jinbiShareLgImg
      jinbiShareMinImg = app.globalData.getGlobalShareMedia.jinbiShareMinImg
      jinbiShareText = app.globalData.getGlobalShareMedia.jinbiShareText
      this.setData({
        teziIsShow:app.globalData.getGlobalShareMedia.teziIsShow
      })
    }else{
      app.getGlobalShareMedia().then(res => {
        jinbiShareLgImg = res.jinbiShareLgImg
        jinbiShareMinImg = res.jinbiShareMinImg
        jinbiShareText = res.jinbiShareText
        this.setData({
          teziIsShow:res.teziIsShow
        })
      })
    }
  },
  onShow() {
    this.tabBar()
  },
  tabBar() {
    if (typeof this.getTabBar === 'function' && this.getTabBar()) {
      this.getTabBar().setData({
        selected: 2
      })
    }
  },
    /**
   * 用户点击右上角分享
   */
  onShareAppMessage(e) {
    return {
      title:jinbiShareText,
      imageUrl:jinbiShareLgImg,
      path: `/pages/jinbi/jinbi`
    }
  },
  onShareTimeline(e) {
    return {
      title:jinbiShareText,
      imageUrl:jinbiShareMinImg,
    }
  },
})